<template>
  <header class="header">
    <h1>todos</h1>
    <input class="new-todo"
      v-model.trim="title" @keyup.enter="add" @keyup.esc="title = ''"
      placeholder="请输入任务名称"
      autofocus
    />
  </header>
</template>
 
<script>
export default {
  name: "hm-header",
  components: {},
  props: {},
  data() {
    return {};
  },
  computed: {},
  watch: {},
  created() {},
  methods: {
    add() {
      if (this.title === "") return alert("输入框不能为空");
      this.$emit("add-event", this.title);
      this.title = "";
    },
  },
};
</script>

<style scoped>
     
</style>